package tech.mobi.child;

import tech.mobi.child.base.BaseAct;
import tech.mobi.child.service.MainService;
import tech.mobi.child.R;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ExitClientAct extends BaseAct implements OnClickListener{

	private Button btnOk;
	private Button btnCancel; 
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.exit_client_main);
		btnOk = (Button) this.findViewById(R.id.btnOk);
		btnCancel = (Button) this.findViewById(R.id.btnCancel);
		btnOk.setOnClickListener(this);
		btnCancel.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btnOk:
			if(MainService.isRunOfService){
				if(MainService.isRun){
					MainService.isRun = false;
				}
				MainService.isRunOfService = false;
				Intent intent = new Intent(this,MainService.class);
				stopService(intent);
			}
			finish();
			MainAct.mainUI.finish();
			//MainService.getActivityByName(InfoNewAct.class.getName()).finish();
			
			//2012-12-18 开始 在1.5.48中更新发布 解决问题如下 
			//at mobi.etong.imobile.modules.info.InfoNewAct.onCreate(InfoNewAct.java:88)
			//at android.app.Activity.performCreate(Activity.java:4533)
			//Log.i("MyLog","MainService-onDestroy");
			for (BaseAct baseAct : MainService.allActivity) {
				baseAct.finish();
			}
			
			MainService.cacheData.clear();
			//2012-12-18 结束 在1.5.48中更新发布 解决问题如下 
			
			
			//2.2以前是可以
			//ActivityManager activityMgr= (ActivityManager) this.getSystemService(ACTIVITY_SERVICE );
			//activityMgr.restartPackage(getPackageName()); 
			//
			android.os.Process.killProcess(android.os.Process.myPid());
			
			break;

		case R.id.btnCancel:
			finish();
			break;
		}
		
	}

	@Override
	public void init() {
		
	}

	@Override
	public void refresh(Object... param) {
		
	}

	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}

	
}


